1. Field of the Invention
The present invention relates to computer programming, and deals more particularly with methods, systems, and computer program products for programmatically serializing complex objects (such as JavaBeans™).
2. Description of the Related Art
For data transfer in distributed computing environments, as well as for storing data persistently, it becomes necessary to convert data structures between structured object format and serialized format. One example of a complex structured object is a JavaBean™, which is an object used when writing programs in the Java™ programming language. (“Java” and “JavaBean” are trademarks of Sun Microsystems, Inc.) Other object-oriented programming languages use different names for their complex structured objects. The term “serialization” is used in the art to describe the process of taking a structured object and transforming it to a “flattened” data structure so that, for example, the contents of the structured object can be persistently stored or can be passed over a network connection in a serial or stream format. “Deserialization” then refers to the reverse process, whereby a flattened data structure is converted into structured object format.
Existing techniques for serializing structured objects require the program developer to manually specify the data mapping type information, at development time, creating a statically-specified type map which is then stored in a mapping registry. These type maps are used as input to a serializer, along with the objects to be serialized. This process is illustrated in FIG. 1, where a complex object 100 and its corresponding type map 110 are input to a serializer 120, which generates a serialized object 130 with type mapping information. This approach has a number of drawbacks, however. First, the programmer is responsible for explicitly specifying mapping information for every object that will be serialized. Complex objects may contain a number of nested objects, some of which may be nested several layers deep, and each object may contain complex data types (such as arrays or vectors). Correctly specifying the mapping information for every object is therefore very labor-intensive, tedious, and error-prone, which results in driving up the cost of providing distributed computing as well as increasing time-to-market for the applications that will use the serialized objects. Furthermore, the manual process of the prior art creates a heavy administrative burden, as any change in the structure of a previously-mapped object (i.e., an object for which a type map has been manually specified) requires the mapping information to be revised to keep it synchronized with the object's current definition.
An additional drawback of requiring a developer to manually create type mappings arises when the serialized object is to be used as input to a complex process such as a “Web service”. (The term “Web service” refers to a trend that is gaining momentum in distributed computing, whereby application code can be dynamically located and accessed in a networking environment. Web services technology is also commonly referred to as the “service-oriented architecture” for distributed computing.) Typically, input messages passed to a Web service are specified using a protocol known as the Simple Object Access Protocol, or “SOAP”. When a serializer generates a datastream to be passed to a Web service using SOAP encoding, the developer is required to understand the syntax, semantics, and encoding rules of the SOAP protocol and to account for these factors when creating the type mappings. This added complexity further increases the time and expense of using prior art serialization techniques.
Accordingly, what is needed are improved techniques for serializing objects.